	Vector.prototype.truncate = function(scalar){
	vl = this.length();
		if(vl>scalar){
		vector=this.x(scalar/vl);
		return vector;
		}
	return this;
	}
	
	Vector.prototype.normalize = function(scalar){
	return this.x(scalar/this.length());
	}
	
	Vector.prototype.length = function(){
	var lengthSquared = 0;
		this.each(function(x, i) {
		lengthSquared += x*x;
		});
	return Math.sqrt(lengthSquared);
	}